from django.db.models.signals import post_save
from django.dispatch import receiver
from .models import Review

@receiver(post_save, sender=Review)
def handle_new_review(sender, instance, created, **kwargs):
    if created:
        instance.order.has_review = True
        instance.order.save()
        
        # 发送通知示例
        from django.core.mail import send_mail
        send_mail(
            f'新评价 - {instance.overall_rating}分',
            instance.comment or '无文字评价',
            'noreply@cookproj.com',
            [instance.chef.user.email],
            fail_silently=True,
        )